package com.kate.mall.product.service.impl;

import com.kate.mall.product.entity.GoodsEntity;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kate.mall.common.utils.PageUtils;
import com.kate.mall.common.utils.Query;

import com.kate.mall.product.dao.GoodsAttributeDao;
import com.kate.mall.product.entity.GoodsAttributeEntity;
import com.kate.mall.product.service.GoodsAttributeService;


@Service("goodsAttributeService")
public class GoodsAttributeServiceImpl extends ServiceImpl<GoodsAttributeDao, GoodsAttributeEntity> implements GoodsAttributeService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<GoodsAttributeEntity> page = this.page(
                new Query<GoodsAttributeEntity>().getPage(params),
                generatorWrapper(params)
        );

        return new PageUtils(page);
    }
    private  QueryWrapper<GoodsAttributeEntity> generatorWrapper(Map<String, Object> params){
        QueryWrapper<GoodsAttributeEntity> queryWrapper = new QueryWrapper<>();
        if(params.containsKey("goods_id")){
            queryWrapper.lambda().eq(GoodsAttributeEntity::getGoodsId,Integer.parseInt(String.valueOf(params.get("goods_id"))));
        }
        //TODO 要不要写逻辑删除条件？？？
        return queryWrapper;
    }

}